﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BestLifePOS_Core.Data.Core;
using BestLifePOS_Core.DomainObjects;
using BestLifePOS_Core.Exceptions.DataBase;
using System.Data.SqlClient;
using System.Data;


namespace BestLifePOS_Core.Data.Commands
{
    class BestLifeUpdatePriceListDataAction : BestLifeDataAction<int>
    {

            private Price_List GvPriceList;
           // private string GvRcptxml;

            public BestLifeUpdatePriceListDataAction(Price_List PPriceList)
            {
                GvPriceList = PPriceList;
                //GvRcptxml = Pxml;
            }

            public override int Body(SqlConnection PConn)
            {
                try
                {
                    SqlCommand LvCommand = new SqlCommand();
                    LvCommand.Connection = PConn;
                    LvCommand.CommandType = CommandType.StoredProcedure;
                    LvCommand.CommandText = "dbo.UpdatePriceList";


                    //LvCommand.Parameters.Add(new SqlParameter("@R_Id", Gvrcpt.R_ID));
                    LvCommand.Parameters.Add(new SqlParameter("@BV", GvPriceList.BV));
                    LvCommand.Parameters.Add(new SqlParameter("@Date_Create", GvPriceList.Date_Create));
                    LvCommand.Parameters.Add(new SqlParameter("@Date_Modify", GvPriceList.Date_Modify));
                    LvCommand.Parameters.Add(new SqlParameter("@Exp_Date", GvPriceList.Exp_Date));
                    LvCommand.Parameters.Add(new SqlParameter("@PL_Id", GvPriceList.PL_Id));
                    LvCommand.Parameters.Add(new SqlParameter("@Pro_ID", GvPriceList.Pro_ID));
                    LvCommand.Parameters.Add(new SqlParameter("@Pro_Price", GvPriceList.Pro_Price));
                    LvCommand.Parameters.Add(new SqlParameter("@Pur_price", GvPriceList.Pur_price));
                    LvCommand.Parameters.Add(new SqlParameter("@PV", GvPriceList.PV));
                    LvCommand.Parameters.Add(new SqlParameter("@Ret_Price", GvPriceList.Ret_Price));
                    LvCommand.Parameters.Add(new SqlParameter("@User_Id", GvPriceList.User_Id));
                    LvCommand.Parameters.Add(new SqlParameter("@User_Modify", GvPriceList.User_Modify));

                    int LvCount = LvCommand.ExecuteNonQuery();
                    return LvCount;


                }
                catch (BestlifeDatabaseException e)
                {
                    throw new BestlifeDatabaseException(e);
                }

            }
    }
}
